#!/usr/bin/python
# -*- coding: utf-8 -*-

import gtk
import webbrowser
from pagewindow import *

def on_click(self, widget, event):

    if self.pointer_on_rest == True:
        # Which button was clicked?
        self.pointer = self.window.get_pointer()
        for idx in range(self.feedrange[self.feedseq]):
            if self.location[idx] < self.pointer[0] < (self.location[idx] + self.width[idx]):
                if event.button == 1:
                    print idx
                    PageWindow(self.feedcontent[self.feedseq].entries[idx].link)
                    break
                elif event.button == 2:
                    webbrowser.open(self.feedcontent[self.feedseq].entries[idx].link)
                    break

                elif event.button == 3:
                    pass


            elif self.inner_logo_location[idx] < self.pointer[0] < (self.inner_logo_location[idx] + self.inner_logo_width):
                if event.button == 1:
                    print idx
                    PageWindow(self.feedcontent[self.feedseq].feed.link)
                    break
                elif event.button == 2:
                    webbrowser.open(self.feedcontent[self.feedseq].feed.link)
                    break

                elif event.button == 3:
                    pass


#                   webbrowser.open(self.feedcontent[self.feedseq].entries[idx].link)
        if event.type == gtk.gdk.BUTTON_PRESS:
            pass
        elif event.type == gtk.gdk._2BUTTON_PRESS:
            pass
        elif event.type == gtk.gdk._3BUTTON_PRESS:
            if not self.feeds[self.feedseq]['RtL']: # direction of movement
                self.xLocation = self.w + 100
            elif self.feeds[self.feedseq]['RtL']: # direction of movement
                self.xLocation = 0
            self.movespeed = 3
